// list-units-sd-bus.cpp

#include <iostream>
#include <systemd/sd-bus.h>

#include "LogCollection.hpp"

#define TEST_ABNORMAL_EXIT false

using LogCollector::Severity;

int main() {
    std::cout << "res=" << \
        static_cast<int>(LogCollector::init()) << std::endl;

    //! 注册异常退出信号的handler
    LogCollector::registerUnexpectedExitHandler();

    //! test for flush timeout
    // LogCollector::setMaxFlushTimeOut(1000);

    for (size_t i = 0; i < 10; i++) {
        SS_LOG_INFO("this is number: %zu", i);
    }

#if TEST_ABNORMAL_EXIT
    //! 构造除零信号 Signal<8>
    volatile int zero = 0;
    int x = 5 / zero;
#endif

    sleep(5);
    LogCollector::deInit();
    return 0;
}